<?php
/**
 * This file is part of the Zhan Framework (http://zhan.com)
 * Copyright © 2015 Zhan, Inc. (http://zhan.com)
 */

namespace Zhan\Event;

use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Zhan\Container\ServiceProvider;
use Zhan\Foundation\Listener\StringToResponseListener;

class EventServiceProvider extends ServiceProvider {

    /**
     * 注册服务至Application
     *
     * @return mixed
     */
    public function register()
    {
        $this->app['events'] = function($app) {
            $dispatcher = new Dispatcher();
            $dispatcher->addSubscriber(new RouterListener($app['matcher']), $app['requestContext']);
            $dispatcher->addSubscriber(new StringToResponseListener());
            return $dispatcher;
        };
    }
}